
import axios, { type AxiosResponse ,type AxiosRequestConfig } from 'axios';
import { ElMessage, ElMessageBox } from 'element-plus';

/* 定义response对象的data接口 */
interface ResponseData<T> {
	code: number;
	data: T;
	message: string;
}

// 配置新建一个 axios 实例
const request = axios.create({
	baseURL: "/mock",
	timeout: 5000,
});


// 添加请求拦截器
request.interceptors.request.use(function (config: AxiosRequestConfig) {
  return config;
}, function (error) {
  return Promise.reject(error);
});

// 添加响应拦截器
request.interceptors.response.use(function (response) {
  return response.data.data;
}, function (error) {
  return Promise.reject(error);
});

export default request;

